# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     day142_pyqt5_qFontDialog
   Description :
   Author :       fuml
   date：          2019/9/22
-------------------------------------------------
   Change Activity:
                   2019/9/22:
                   In this example, we determine the event sender object.
-------------------------------------------------
"""
import sys
from PyQt5.QtWidgets import QWidget,QVBoxLayout,QPushButton,QSizePolicy,QLabel,QFontDialog,QApplication

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        vbox = QVBoxLayout()
        btn = QPushButton('Dialog',self)
        btn.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed)
        btn.move(20,20)

        vbox.addWidget(btn)

        btn.clicked.connect(self.showDialog)
        self.lbl = QLabel('Knowledge only matters',self)
        self.lbl.move(20,50)

        vbox.addWidget(self.lbl)
        self.setLayout(vbox)

        self.setGeometry(300,300,250,180)
        self.setWindowTitle('Font Dialog')
        self.show()
    def showDialog(self):
        font , ok = QFontDialog.getFont()
        if ok:
            self.lbl.setFont(font)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())